﻿@using Orchard.ContentManagement
@using Orchard.Comments
@using Orchard.Comments.Models

@{
    CommentPart comment = Model.ContentPart;
    CommentsPart comments = comment.CommentedOnContentItem.As<CommentsPart>();
    var isAuthorized = AuthorizedFor(Permissions.AddComment, Model.ContentItem);
    
    var children = New.List(Items: Model.Items);
    children.Classes.Add("comments");

    if (Model.Items.Count > 0) {
        Model.Classes.Add("has-replies");
    }
    
    Model.Classes.Add("comment");

    Model.Id = "comment-" + comment.Id;
    var tag = Tag(Model, "article");
}
@tag.StartElement
    <header>
        <h4>
            <span class="who">@Display.CommentAuthor(ContentPart: comment)</span>
            <span class="when">@Display.CommentMetadata(ContentPart: comment)</span>
            @if (comments.ThreadedComments && comments.CommentsActive && isAuthorized) {
                @Display.CommentReplyButton(ContentPart: comment)
            }
        </h4>
    </header>

    @Display.CommentText(ContentPart: Model.ContentPart, ContentItem: Model.ContentItem)

    @Display(children)
@tag.EndElement
